package FactoryMode

import scala.io.StdIn
import scala.util.control.Breaks.{break, breakable}

object PizzaStore {
  def main(args: Array[String]): Unit = {
    val orderPizza = SimpleFactory.createPizza("greek")
    println(orderPizza)

  }
}

abstract class Pizza {
  var name: String = _

  def prepare()

  def bake()

  def box()
}

class GreekPizza extends Pizza {
  override def prepare(): Unit = {}

  override def bake(): Unit = {}

  override def box(): Unit = {}


  override def toString = s"GreekPizza(prepare=$prepare, bake=$bake, box=$box)"
}

class CheesPizza extends Pizza {
  override def prepare(): Unit = ???

  override def bake(): Unit = ???

  override def box(): Unit = ???
}

class HuziPizza extends Pizza {
  override def prepare(): Unit = ???

  override def bake(): Unit = ???

  override def box(): Unit = ???
}

class NOrderPizza {
  var orderType: String = _
  var pizza: Pizza = _
  breakable {
    do {
      println("请输入pizza的类型")
      orderType = StdIn.readLine()
      if (orderType.eq("greek")) {
        this.pizza = new GreekPizza
      } else if (orderType.eq("huzi")) {
        this.pizza = new HuziPizza
      } else {
        break()
      }
      this.pizza.prepare()
      this.pizza.bake()
      this.pizza.box()
    } while (true)

  }

}